libxl: Prevent xl save from segfaulting when control/shutdown key is removed
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 23 Nov 2011 12:03:37 +0000 (12:03 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Wed, 23 Nov 2011 12:03:37 +0000 (12:03 +0000)
To acknowledge the tools' setting of control/shutdown it is normal for
PV drivers to rm the key. This leads to libxl__xs_read() returning
NULL and thus a subsequent strcmp on the return value will cause a
segfault.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_dom.c

index d810655d9c4326c73b00df2d4822dd440e9dfaa2..349eab6daba249bc050ffd23931a80870407b576 100644 (file)
@@ -444,6 +444,7 @@ static int libxl__domain_suspend_common_callback(void *data)
             usleep(100000);
 
             state = libxl__xs_read(si->gc, XBT_NULL, path);
+            if (!state) state = "";
 
             watchdog--;
         }
@@ -463,6 +464,7 @@ static int libxl__domain_suspend_common_callback(void *data)
             t = xs_transaction_start(ctx->xsh);
 
             state = libxl__xs_read(si->gc, t, path);
+            if (!state) state = "";
 
             if (!strcmp(state, "suspend"))
                 libxl__xs_write(si->gc, t, path, "");